<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>helloVue</title>
</head>
<body>
<div id="hv">
    <h1>{{info}}</h1>
    <input type="button" value="开始读秒"@click="start()">
    <input type="button" value="Stop"@click="stop()">
    <div>{{second}}</div>
</div>
<script src="vue.js"></script>
<script>
    let v=new Vue({
        el:"#hv",
        data:{
            info:"hello Vue!!!",
            second:0,
            timer:"",
            /*把两个方法共有的参数放入变量中，能共同使用*/
        },
        methods:{
            start(){
                 v.timer=setInterval(function () {
                    v.second++;
                },100)
            },
            stop(){
                clearInterval(v.timer);
            }
        }
    })
</script>
</body>
</html>